/**
 * ZHU framework. Copyright 2012-, all rights reserved.
 *
 * $Id: PeriodType.java 28 2012-08-28 01:03:28Z zhuxiaopeng $
 * $Revision: 28 $
 * $Date: 2012-08-28 09:03:28 +0800 (二, 2012-08-28) $
 * $Author: zhuxiaopeng $
 */
package daily.web.period;

import java.util.*;

import daily.util.*;

/**
 * <p>
 * </p>
 * 
 * @author $Author: zhuxiaopeng $
 * @version $Revision: 28 $ - $Date: 2012-08-28 09:03:28 +0800 (二, 2012-08-28) $
 */
public enum PeriodType {
	WEEK {
		@Override
		Date next(final Date date) {
			return DateUtils.getCalculateDayDate(date, 7);
		}

		@Override
		Date prior(final Date date) {
			return DateUtils.getCalculateDayDate(date, -7);
		}

		@Override
		Date getStartDate(final Date date) {
			return DateUtils.getFirstDayOfWeek(date);
		}

		@Override
		Date getEndDate(final Date date) {
			return DateUtils.getLastDayOfWeek(date);
		}
	},
	MONTH {
		@Override
		Date next(final Date date) {
			return DateUtils.getCalculateMonthDate(date, 1);
		}

		@Override
		Date prior(final Date date) {
			return DateUtils.getCalculateMonthDate(date, -1);
		}

		@Override
		Date getStartDate(final Date date) {
			return DateUtils.getFirstDayOfMonth(date);
		}

		@Override
		Date getEndDate(final Date date) {
			return DateUtils.getLastDayOfMonth(date);
		}
	};
	abstract Date next(Date date);

	abstract Date prior(Date date);

	abstract Date getStartDate(Date date);

	abstract Date getEndDate(Date date);
}
